home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 334 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.1 KB

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: clamage@Eng.sun.com (Steve Clamage)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: and, or, not
  5. Date: 7 Feb 1996 21:13:26 GMT
  6. Organization: Sun Microsystems Inc.
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <4fb3f5$or1@engnews1.Eng.Sun.COM>
  9. References: <3118FDEF.458E@bridge.com>
  10. Reply-To: clamage@Eng.sun.com
  11. NNTP-Posting-Host: taumet.eng.sun.com
  12. Content-Type: text
  13. X-Nntp-Posting-Host: taumet.eng.sun.com
  14. Content-Length: 1443
  15. X-Lines: 47
  16. Originator: clamage@taumet
  17.  
  18. In article 458E@bridge.com,  Rod Burman <rodb@bridge.com> writes:
  19. >
  20. >> >>                   Table 4--alternative representations
  21. >> >
  22. >> >>            +------------------------------------------------+
  23. >> >>            |and      and_eq   bitand   bitor   compl    not |
  24. >> >>            |not_eq   or       or_eq    xor     xor_eq       |
  25. >> >>            +------------------------------------------------+
  26. >>         YET
  27. >> >This leads to ^ another question:
  28. >
  29. >Is the committee thinking of some how linking these with operator 
  30. >overloading?
  31. >    e.g.    operator^() == operator.xor() xor operator_xor()
  32. >
  33. >or do you just use trigraphs for this particular usage?
  34.  
  35. When you write
  36.     operator^()
  37. that phrase consists of four tokens:
  38.     operator  ^  (  )
  39.  
  40. The "^" token can be spelled in three ways:
  41.     ^
  42.     xor
  43.     ??'
  44. All three spellings are equivalent, and it doesn't matter which you use
  45. when referring to the operator. So you could write:
  46.  
  47.     int operator^(const T&, const T&); // declare function
  48.     T a, b, c, d, e, f;
  49.     ...
  50.     int i = a ^ b;            // call function 3 times
  51.     int j = c ??' d;
  52.     int k = operator xor(e, f);
  53.     ...
  54.     int operator??'(const T& t1, const T& t2) { ... } implement function
  55.  
  56. The only time a difference shows up in the token spellings is if you
  57. "stringize" the token via a "#" in a macro.
  58.     # ^   becomes "^"
  59.     # ??' becomes "^"    // because ??' is converted to ^ before anything else
  60.     # xor becomes "xor"
  61. ---
  62. Steve Clamage, stephen.clamage@eng.sun.com
  63.  
  64.  
  65.  
  66. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  67.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy is
  68.   summarized in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  69. ]
  70.